#pragma once
#include"../net/campus_whole_server.h"
#include<map>

struct HdlComparer{
    bool operator()(websocketpp::connection_hdl a, websocketpp::connection_hdl b) const{
        return a.lock().get() < b.lock().get();
    }
};

using json = nlohmann::json;
class CampusLiveInfoManager
{
public:
    CampusLiveInfoManager(CampusWholeServer* whole_server);
    ~CampusLiveInfoManager();

    // -------------------------- 业务回调接口（供WholeManager转发）--------------------------
    void handleLiveJoin(websocketpp::connection_hdl hdl, json JMsg);
    void handleLiveChat(websocketpp::connection_hdl hdl, json JMsg);
    void handleLiveLeave(websocketpp::connection_hdl hdl);

private:
    void doAddLiveInfo(websocketpp::connection_hdl hdl, json JMsg);
    void doSendLiveChat(websocketpp::connection_hdl hdl, json JMsg);
    void doRemoveLiveInfo(websocketpp::connection_hdl hdl);

private:    
    CampusWholeServer* whole_server_;               
    std::map<websocketpp::connection_hdl, CampusLiveInfo, HdlComparer> live_join_map_; //hdl-CampusLiveInfo
};